#include <iostream>

using std::cout;
using std::endl;

class Point
{
public:
    Point(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    {
        cout << "Point(int = 0, int = 0)" << endl;
    }

    void print() const
    {
        cout << "(" << this->_ix 
             << ", " << this->_iy
             << ")" << endl;
    }

    ~Point()
    {
        cout << "~Point()" << endl;
    }

private:
    int _ix;
    int _iy;
};

void test()
{
    int a = 1;
    int *p1 = nullptr;
    p1 = &a;

    Point pt1(1, 2);//栈对象
    cout << "pt1 = ";
    pt1.print();

    Point *ppt = nullptr;
    ppt = &pt1;

    cout << endl;
    int *pInt = new int(10);
    Point *ppt2 = new Point(1, 2);
    Point *ppt3;//

}

void test2()
{
    int arr[5] = {1, 2, 3, 4};

    Point pt1(10, 20);

    Point pt[5] = {Point(1, 2), Point(3, 4), Point(5, 6), pt1};
    pt[0].print();

    cout << endl << "-------------------" << endl;
    //逗号表达式
    //a = b,c,d,e
    /* Point ppt[5] = {(1, 2), (3, 4)}; */
    Point ppt[5] = {{1, 2}, {3, 4}};
    cout << "ppt[0] = ";
    ppt[0].print();
}

void test3()
{
    //int *pInt = new int(10);
    Point *pt = new Point(1, 2);

    delete pt;
    pt = nullptr;

    //int *pp = new int[10]();
    Point *pArray = new Point[10]();

    /* delete [] pArray; */
    /* pArray = nullptr; */
    free(pArray);
    pArray = nullptr;
}

int main(int argc, char **argv)
{
    test3();
    return 0;
}

